<template>
	<view>
		<view class="position_recommendation">
			<view class="">
				<view class="position_recommendation_bottom" @click="positionDetail(item)"
					v-for="(item,index) in dataList" :key="index">
					<view class="prb_top dis_flex">
						<view class="prb_top_left dis_flex">
							<text>{{item.postType}}</text>
							<image v-if="item.state=='111111'"  src="../../static/icon/tuijian.png" mode="" />
						</view>
						<!-- <image @click="collZWTJ(1)" :src="sc_imgurl" mode=""></image> -->
						<!-- <image v-show="item.follow==undefined"  @click.stop='activeFollow==false?guanzhu(item):""' :src="sc_imgurl" mode="">
						</image> -->
						<!-- 已关注 -->
						<!-- <image v-show="item.follow!=undefined" @click.stop='activeFollow==true?quxiao(item):""' :src="qx_imgurl" mode="">
						</image> -->
						<image @click.stop="collZWTJ(item,index)" :src="item.follow==undefined?item.imgurl:item.imgurl"
							mode=""></image>

					</view>
					<view class="prb_center dis_flex">
						<view class="prb_center_left dis_flex">
							<!-- <text>{{item.money}}</text> -->
							<text>{{item.background}}</text>
							<text>{{item.education}}</text>
						</view>
						<text class="tit">{{item.salary}}</text>
					</view>
					<view class="prb_bottom dis_flex">
						<view class="prb_bottom_left dis_flex">
							<image :src="webImgUrl+item.companyCard" mode=""></image>
							<text>{{item.companyName}}</text>
						</view>
						<text>{{item.reviewTime}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		
		data() {
			return {
				dataList: [],
				follow: 'false',
				webImgUrl: '',
				active_img: true,
				activeFollow: false,
				watchData: [],
				sc_imgurl: '../../static/icon/shoucang.png',
				qx_imgurl: '../../static/icon/shoucang2.png',
				dataMain: {
					baseId: '', //用户id
					target: 'findrt', //关注类型   findrt-招聘   findjb
					targetId: '', //对象id
				},
				tuijian: {
					currentPage: 1,
					pageSize: 10,
					userId: ''
				},
				searchForm: {
					type: "",
					search: '',
					currentPage: 1,
					pageSize: 10,
					userId: ''
				},
			}
		},
		computed: {
			baseid() {
				return this.$store.state.userId
			}
		},
		created() {
			this.webImgUrl = this.$webUrl
			this.dataMain.baseId = this.baseid
			this.tuijian.userId = this.baseid
			this.searchForm.userId = this.baseid
			this.getTJrecommend(this.tuijian)
		},

		methods: {
			// 强制刷新、重新加载页面
			foreData(){
				this.$forceUpdate()
			},
			// 刷新职位
			getSearch(data) {
				this.$myResquest.getRecruitSearch(data).then(res => {
					if (res.data.code == 200) {
						this.dataMain = res.data.data
						for (var i = 0; i < this.dataList.length; i++) {
							if (this.dataList[i].follow == undefined) {
								this.$set(this.dataList[i], "imgurl", '../../static/icon/shoucang.png')
							}
							if (this.dataList[i].follow != undefined) {
								this.$set(this.dataList[i], "imgurl", '../../static/icon/shoucang2.png')
								
							}
						}
					}
				})
			},
			//职位推荐接口
			getTJrecommend(data) {
				this.$myResquest.getTJrecommend(data).then(res => {
					if (res.data.code == 200) {
						this.dataList = res.data.data
						for (var i = 0; i < this.dataList.length; i++) {
							if (this.dataList[i].follow == undefined) {
								this.$set(this.dataList[i], "imgurl", '../../static/icon/shoucang.png')
							}
							if (this.dataList[i].follow != undefined) {
								this.$set(this.dataList[i], "imgurl", '../../static/icon/shoucang2.png')
							
							}
						}
					}
				})
			},
			// 职位详情
			positionDetail(item) {
				// id为当前行的id
				uni.navigateTo({
					url: '../../pageB/zhaopin1/positiondetail?id=' + item.recruitId + '&follow=' + item.follow
				})
			},
			guanzhu(item) {
				this.$set(item, {
					show: false
				})
				this.activeFollow = !this.activeFollow
				this.sc_imgurl = '../../static/icon/shoucang2.png'
			},
			quxiao(item) {
				this.activeFollow = !this.activeFollow
				this.qx_imgurl = '../../static/icon/shoucang.png'
			},
			// 职位推荐、人才推荐收藏方法
			collZWTJ(item, index) {
				this.dataMain.targetId = item.recruitId
				if (item.follow == undefined) {
					this.$myResquest.peronFollow(this.dataMain).then(res => {
						if (res.data.code == 200) {
							this.active_img = true
							// this.sc_imgurl = '../../static/icon/shoucang2.png'
							// 添加
							this.$set(this.dataList[index], 'follow', '111111')
							this.dataList[index].imgurl = '../../static/icon/shoucang2.png'
						}
					})

				} else {
					this.$myResquest.peronDisfollow(this.dataMain).then(res => {
						if (res.data.code == 200) {
							this.active_img = false
							// this.dataList[index].qx_imgurl = '../../static/icon/shoucang.png'
							// 添加
							this.$delete(this.dataList[index], 'follow')
							this.dataList[index].imgurl = '../../static/icon/shoucang.png'
						}
					})

				}

			}
		}
	}
</script>

<style lang="scss" scoped>
	.position_recommendation {
		background: #FFFFFF;

		.position_recommendation_head {
			height: 76rpx;
			display: flex;
			justify-content: space-between;
			padding: 0 8rpx;
			box-sizing: border-box;

			&:first-child {
				font-size: 32rpx;
				font-family: PingFang SC, PingFang SC-Bold;
				font-weight: 700;
				text-align: left;
				color: #5cd1ce;
			}

			.more {
				font-size: 24rpx;
				font-family: PingFang SC, PingFang SC-Medium;
				font-weight: 500;
				text-align: center;
				color: #999999;
			}
		}

		.position_recommendation_bottom {
			width: 100%;
			// min-width: 351px;
			height: 238rpx;
			padding: 0 16rpx;
			margin-top: 26rpx;
			box-sizing: border-box;
			background: #ffffff;
			border-radius: 10rpx;
			box-shadow: 0px 0px 18rpx 0px rgba(0, 0, 0, 0.1);

			&:first-child {
				margin-top: 0;
			}

			.prb_top {
				height: 80rpx;

				.prb_top_left {
					image {
						margin-left: 14rpx;
						width: 46rpx;
						height: 36rpx;
					}
				}

				image {
					width: 36rpx;
					height: 34rpx;
				}
			}

			.prb_center {
				.tit {
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC-Medium;
					font-weight: 500;
					text-align: left;
					color: #f46969;
				}

				.prb_center_left {
					text {
						text-align: center;
						min-width: 112rpx;
						height: 40rpx;
						margin: 0 4rpx;
						line-height: 40rpx;
						box-sizing: content-box;
						background: #f2f2f2;
						border-radius: 6rpx;
					}
				}
			}

			.prb_bottom {
				margin-top: 30rpx;

				.prb_bottom_left {
					image {
						width: 50rpx;
						height: 50rpx;
						margin-right: 14rpx;
						border-radius: 50%;

						text {
							font-size: 24rpx;
							font-family: PingFang SC, PingFang SC-Medium;
							font-weight: 500;
							text-align: left;
							color: #999999;
						}
					}
				}

				text {
					font-size: 24rpx;
					font-family: PingFang SC, PingFang SC-Medium;
					font-weight: 500;
					text-align: left;
					color: #999999;
				}
			}
		}

	}
</style>
